﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace B2BServer
{
    /// <summary>
    /// Class for options form
    /// </summary>
    public partial class OptionsForm : Form
    {
        /// <summary>
        /// Function to initialise the options form
        /// </summary>
        public OptionsForm()
        {
            InitializeComponent();
        }

        private void OptionsForm_Load(object sender, EventArgs e)
        {
            #region load strings
            //Log string load start
            B2BCore.LogHelper.Log("Options Form String Load", System.Diagnostics.TraceEventType.Start);
            //load strings
            this.Text = string.Format(Strings.Generic.WindowTitleFormName, Strings.Generic.FormNameOptions);
            optionsPageGeneral.Text = Strings.OptionsForm.TabGeneral;
            optionsPageChat.Text = Strings.OptionsForm.TabChat;
            optionsPageSecurity.Text = Strings.OptionsForm.TabSecurity;

            lblLogBack.Text = Strings.OptionsForm.lblLogBack;
            lblLogFore.Text = Strings.OptionsForm.lblLogFore;
            lblExample.Text = Strings.OptionsForm.lblExample;
            lblPassword.Text = Strings.OptionsForm.lblPassword;
            lblLockOnLoad.Text = Strings.OptionsForm.lblLockOnLoad;
            //Log string load finish
            B2BCore.LogHelper.Log("Options Form String Load", System.Diagnostics.TraceEventType.Stop);
            #endregion
            #region load settings
            if (GlobalVariables.password != String.Empty)
            {
                txtPassword.Text = "_____";
            }
            else
            {
                txtPassword.Text = "";
            }

            lblExample.ForeColor = GlobalVariables.logforecolour;
            txtLogForeColour.BackColor = GlobalVariables.logforecolour;
            lblExample.BackColor = GlobalVariables.logbackcolor;
            txtLogBackColour.BackColor = GlobalVariables.logbackcolor;
            chkLock.Checked = GlobalVariables.lockonload;
            #endregion
        }

        private void btnPasswordHelp_Click(object sender, EventArgs e)
        {
            GlobalFunctions.ShowHelp(Strings.OptionsForm.HelpPassword);
        }

        private void btnLogForeChange_Click(object sender, EventArgs e)
        {
            colorDialog.ShowDialog();
            txtLogForeColour.BackColor = colorDialog.Color;
            lblExample.ForeColor = txtLogForeColour.BackColor;
        }

        private void btnLogBackChange_Click(object sender, EventArgs e)
        {
            colorDialog.ShowDialog();
            txtLogBackColour.BackColor = colorDialog.Color;
            lblExample.BackColor = txtLogBackColour.BackColor;
        }

        private void btnLogForeHelp_Click(object sender, EventArgs e)
        {
            GlobalFunctions.ShowHelp(Strings.OptionsForm.HelpLogFore);
        }

        private void btnLogBackHelp_Click(object sender, EventArgs e)
        {
            GlobalFunctions.ShowHelp(Strings.OptionsForm.HelpLogBack);
        }

        private void btnOK_Click(object sender, EventArgs e)
        {

        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void btnHelpLock_Click(object sender, EventArgs e)
        {
            GlobalFunctions.ShowHelp(Strings.OptionsForm.HelpLockOnLoad);
        }
    }
}
